package com.wehealth.electrocardiograph_two_client.activity

import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
  import com.wehealth.electrocardiograph_two_client.R
import com.wehealth.electrocardiograph_two_client.databinding.ActivityHtmlBinding
import com.wehealth.electrocardiograph_two_client.presenter.HtmlPresenter
import com.wehealth.electrocardiograph_two_client.utils.FileUtils
import com.wehealth.three.lib_common.route.RouteFlag
import com.wehealth.three.lib_common.route.RouteHelper
import com.wehealth.three.lib_common.ui.component.BaseActivity
import com.wehealth.three.lib_common.utils.ResUtlis
import com.wehealth.three.lib_connect.constant.ConstantKey
import com.wehealth.three.lib_connect.constant.ConstantKey.adb_command_typec

@Route(path = RouteFlag.html_page)
class HTMLActivity : BaseActivity<ActivityHtmlBinding>(
    barColor = ResUtlis.getColor(R.color.title_back_color),
    darkContent = false,
    translucent = false
) {
    @JvmField
    @Autowired
    var type: String? = null

    @JvmField
    @Autowired
    var url: String? = null

    @JvmField
    @Autowired
    var title: String? = null

    lateinit var presenter: HtmlPresenter

    override fun getLayoutId(): Int {
        return R.layout.activity_html
    }

    override fun initData() {
        RouteHelper.inject(this)
        presenter = HtmlPresenter(HTMLActivity@ this, dataBinding)
        if (title != null && url != null) {
            presenter.loadContent(title!!, url!!)
        }
        dataBinding.htmlBack.setOnClickListener {
            finish()
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        FileUtils.writeContentToFile(
            ConstantKey.adb_command_dir,
            adb_command_typec.toCharArray())

    }
}